#include <iostream>

using namespace std;

const int N = 200;
char a[N][N]; 
int b[N][N];
int n, m;

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            cin >> a[i][j];
            if(a[i][j] == '*')
            {
                b[i][j - 1]++;
                b[i][j + 1]++;
                b[i + 1][j - 1]++;
                b[i + 1][j]++;
                b[i + 1][j + 1]++;
                b[i - 1][j - 1]++;
                b[i - 1][j]++;
                b[i - 1][j + 1]++;
            } 
        }
    }
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
        {
            if(a[i][j] == '*') cout << '*';
            else cout << b[i][j];
        }
        cout << endl;
    }
    return 0;
}